package ink.lovejinhu.leetcode;

/**
 * @Author: jin
 * @Date: 2021/8/25 10:32
 * @Version: V1.0
 * @Slogan: Great people are not born great, but show their greatness in the process of growing up
 **/
public class Solution_0832 {
    /**
     * 图像先翻转，在反转
     * a[i][j]   =a[i][length-1-j]
     *
     * @param image
     * @return
     */
    public int[][] flipAndInvertImage(int[][] image) {
        for (int i = 0; i < image.length; i++) {
            int left = 0, right = image[0].length - 1;
            for (; left < right; left++, right--) {
                int temp = image[i][left];
                image[i][left] = (image[i][right] + 1) % 2;
                image[i][right] = (temp + 1) % 2;
            }
            if (left==right){
                image[i][left]=(image[i][left]+1)%2;
            }
        }
        return image;
    }
}
